package com.edu.exam.enums.examination;

/**
 * 监控风险级别枚举
 *
 * <p>监控任务的风险级别定义。</p>
 *
 * @author 系统生成
 * @version 1.0
 * @since 2025-11-14
 */
public enum MonitoringRiskLevel {

    /** 低 */
    LOW("LOW", "低"),

    /** 中 */
    MEDIUM("MEDIUM", "中"),

    /** 高 */
    HIGH("HIGH", "高"),

    /** 关键 */
    CRITICAL("CRITICAL", "关键");

    private final String code;
    private final String description;

    MonitoringRiskLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static MonitoringRiskLevel fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            throw new IllegalArgumentException("Monitoring risk level code cannot be null or empty");
        }

        for (MonitoringRiskLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown monitoring risk level code: " + code);
    }

    public static MonitoringRiskLevel fromDescription(String description) {
        for (MonitoringRiskLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return this.code + "(" + this.description + ")";
    }
}
